package com.cencus.controller;

import com.cencus.domain.Code;
import com.cencus.domain.Tag;
import com.cencus.service.TagService;
import com.cencus.service.impl.TagServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/tags")
public class TagController {
    @Autowired
    private TagServiceImpl tagService;

    @GetMapping
    public Result getAllTags(){
        return new Result(Code.OK,tagService.getAllTags());
    }
    @GetMapping("/{name}")
    public Result searchTag(@PathVariable String name){
        return new Result(Code.OK,tagService.searchTag(name));
    }

    @PostMapping("/{name}")
    public Result createTag(@PathVariable String name){
        return new Result(Code.OK,tagService.createTag(name));
    }
    @DeleteMapping("/{tagId}")
    public Result deleteTag(@PathVariable Integer tagId){
        return new Result(Code.OK,tagService.deleteTag(tagId));
    }
}
